// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
const { REACT_APP_ENV } = process.env;
export default defineConfig({
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  // mfsu: { production: { output: '.mfsu-production' } },
  history: {
    type: 'hash',
  },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    antd: true,
    // default true, when it is true, will use `navigator.language` overwrite default
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/',
      component: '../layouts/BlankLayout',
      routes: [
        {
          path: '/user',
          component: '../layouts/UserLayout',
          routes: [
            {
              path: '/user/login',
              name: 'login',
              component: './User/login',
            },
            {
              path: '/user',
              redirect: '/user/login',
            },
            {
              component: '404',
            },
          ],
        },
        {
          path: '/',
          component: '../layouts/BasicLayout',
          Routes: ['src/pages/Authorized'],
          authority: ['admin', 'user'],
          routes: [
            {
              path: '/',
              redirect: '/platform/book',
            },
            {
              path: '/platform',
              icon: 'form',
              name: '约车平台',
              routes: [
                {
                  path: '/',
                  redirect: '/platform/book',
                },
                {
                  name: '预约车辆',
                  icon: 'smile',
                  path: '/platform/book',
                  component: './platform/book',
                },
                {
                  name: '任务标签管理',
                  icon: 'smile',
                  path: '/platform/taskTag',
                  component: './platform/taskTag',
                },
                {
                  name: '司机管理',
                  icon: 'smile',
                  path: '/platform/driver',
                  component: './platform/driver',
                },
                {
                  name: '测试人员管理',
                  icon: 'smile',
                  path: '/platform/tester',
                  component: './platform/tester',
                },
              ],
            },
            {
              path: '/manage',
              icon: 'table',
              name: '车辆管理',
              routes: [
                {
                  path: '/',
                  redirect: '/manage/cars',
                },
                {
                  name: '车辆列表',
                  icon: 'smile',
                  path: '/manage/cars',
                  component: './manage/cars',
                },
                {
                  name: '维保信息',
                  icon: 'smile',
                  path: '/manage/maintenance',
                  component: './manage/maintenance',
                },
              ],
            },
            {
              path: '/permits',
              name: '配置用户权限',
              icon: 'profile',
              authority: [1, 4],
              routes: [
                {
                  path: '/',
                  redirect: '/permits/basic',
                },
                {
                  name: '用户配置',
                  icon: 'smile',
                  path: '/permits/basic',
                  component: './permits/basic',
                },
                {
                  name: '权限配置',
                  icon: 'smile',
                  path: '/permits/config',
                  component: './permits/config',
                },
              ],
            },
            {
              path: '/echart',
              name: '统计',
              icon: 'profile',
              routes: [
                {
                  path: '/',
                  redirect: '/echart/basic',
                },
                {
                  name: '统计',
                  icon: 'smile',
                  path: '/echart/basic',
                  component: './echart/basic',
                },
              ],
            },
            {
              component: '404',
            },
          ],
        },
      ],
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    'primary-color': defaultSettings.primaryColor,
  },
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
  esbuild: {},
});
